<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title></title>
    <style>
    * {
      padding: 0;
      margin: 0;
      box-sizing: border-box;
    }
    .father {
      width: 80%;
      height: 100px;
      background-color: pink;
      display: flex;
    }
    .father2 {
      width: 80%;
      height: 100px;
      background-color: pink;
      display: flex;
      /* 通过padding缩小子级可用空间 */
      padding-left: 100px;
    }
    .son {
      background-color: red;
      flex: 1;
    }
    .son:nth-child(2n) {
      background-color: yellow;
      flex: 2;
    }
    /* 子级每份都是1，用于验证上面两个父级的第二个子级占了2份 */
    .father4 .son:nth-child(2n) {
      background-color: yellow;
      flex: 1;
    }
    /* 给子级设置margin border padding，用于验证flex按份数分大小时，这些内容不占份额 */
    .father .son:nth-child(1) {
      margin-left: 50px;
      border-left: 25px solid black;
      padding-left: 25px;
    }
    </style>
    <link href="css/style.css" rel="stylesheet">
  </head>
  <body>
    <div class="father">
      <div class="son">1</div>
      <div class="son">2</div>
      <div class="son">3</div>
    </div>
    <div class="father2">
      <div class="son">1</div>
      <div class="son">2</div>
      <div class="son">3</div>
    </div>
    <div class="father2 father4">
      <div class="son">1</div>
      <div class="son">2</div>
      <div class="son">3</div>
      <div class="son">4</div>
    </div>
    <p>现象：在设置box-sizing: border-box;后，下方父级padding-left宽度等于上方子级margin-left,border-left,padding-left之和，上下子级div是对齐的</p>
    <p>flex代表的份数，是先去除那些有固定长度的内容(父级的margin，子级的margin border padding)后，剩下内容按份数占比来分配宽度</p>
  
  </body>
</html>
